﻿@using System.Linq.Expressions;
@using Microsoft.AspNetCore.Authorization;
@using Microsoft.Extensions.Logging
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Admin.Blazor
@using ThingsGateway.Core.Extension
@using ThingsGateway.Gateway.Application
@namespace ThingsGateway.Plugin.SqlHisAlarm
@inject UserResoures UserResoures
@inherits BaseComponentBase



<MCard MinHeight=120 Rounded=true Elevation=1 Class="ma-2">
    <MCardSubtitle Class="text-subtitle-1">
        @AppService.I18n.T("周统计")
    </MCardSubtitle>
    <MDivider></MDivider>
    <MRow Class="pa-4" NoGutters Align="AlignTypes.Center" Justify="JustifyTypes.Start">

         <MECharts Option="eChartsOption" Width="@("100%")" MinHeight="300"></MECharts>

     </MRow>
 </MCard>



 <AppDataTable @ref="_datatable" TItem="HistoryAlarm" SearchItem="HistoryAlarmPageInput"
               AddItem="object" EditItem="object" IsShowSelect=false
               SearchModel="@_search" IsShowOperCol=true
               QueryCallAsync="QueryCallAsync" FirstQuery=false
                IsShowDetailButton IsShowQueryButton >
    <SearchTemplate>

        <PDateTimePicker @bind-Value="context.StartTime"
                         TimeFormat="TimeFormat.Hr24"
                         ViewType="DateTimePickerViewType.Compact">
            <ActivatorContent Context="dt">
                <MTextField @bind-Value="context.StartTime" Label=@AppService.I18n.T(context.Description(x => x.StartTime))
                                    Clearable Class="my-1  mx-2 "
                                    Filled Outlined
                                    Readonly Dense
                             @attributes="@dt.Attrs">
                 </MTextField>
             </ActivatorContent>
             </PDateTimePicker>

             <PDateTimePicker @bind-Value="context.EndTime"
                              TimeFormat="TimeFormat.Hr24"
                              ViewType="DateTimePickerViewType.Compact">
             <ActivatorContent Context="dt">
                 <MTextField @bind-Value="context.EndTime" Label=@AppService.I18n.T(context.Description(x => x.EndTime))
                                    Clearable Class="my-1  mx-2 "
                                    Filled Outlined
                                    Readonly Dense
                             @attributes="@dt.Attrs">
                 </MTextField>
             </ActivatorContent>
             </PDateTimePicker>


             <MSelect Class="my-1 mx-2 " Items=@(typeof(EventTypeEnum).GetEnumList()) Style="max-width:300px;"
                      @bind-Value=@context.EventType Label=@(context.Description(x => x.EventType))
                      MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
                      ItemText=@(u =>u.Description)
                      ItemValue=@(u =>(EventTypeEnum)u.Value)
                  Dense HideDetails=@("auto")
                  Outlined></MSelect>

         <MSelect Class="my-1 mx-2 " Items=@(typeof(AlarmTypeEnum).GetEnumList()) Style="max-width:300px;"
                  @bind-Value=@context.AlarmType Label=@(context.Description(x => x.AlarmType))
                  MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
                  ItemText=@(u =>u.Description)
                  ItemValue=@(u =>(AlarmTypeEnum)u.Value)
                  Dense HideDetails=@("auto")
                  Outlined></MSelect>

         <MTextField Dense Style="max-width:200px;" HideDetails=@("auto") Class="my-1 mx-2 " Outlined
                     @bind-Value="context.VariableName" Label=@AppService.I18n.T(context.Description(x => x.VariableName)) />



     </SearchTemplate>


     </AppDataTable>



